@ECHO OFF

chcp 65001

:: 把java_home设置为agent同级的jre服务地址；
set JAVA_HOME=%cd%\jdk
set jdk_Home=%JAVA_HOME%
set PATH=%JAVA_HOME%\bin;%SystemRoot%;%SystemRoot%\System32;%PATH%

::输出环境变量
echo java_home is %JAVA_HOME%
echo jdk_Home is %jdk_Home%
echo PATH is %PATH%

::输出java版本
java -version

::判断应用是否已经启动
set num=0
for /f "tokens=1" %%a in ('jdk\bin\jps -v^|findstr PickToolApplication') do (
  echo AsrAgentStart pid is %%a
  set /a num += 1
)
if %num% gtr 0 (
  echo started
  PAUSE
  goto :eof
) else (
  echo no started
)

::除了本应用所需要的依赖包之外，还需要jdk中带的运行依赖包，尤其是javafx 所需要的；
:startup
SET CLASSPATH=.
FOR %%F IN (jdk\lib\*.jar) DO CALL :addcp %%F
FOR %%F IN (jdk\lib\ext\*.jar) DO CALL :addcp %%F
FOR %%F IN (lib\*.jar) DO CALL :addcp %%F
GOTO exitlib

:addcp
echo %1
SET CLASSPATH=%CLASSPATH%;%1
GOTO :eof

:exitlib
SET osbit=%PROCESSOR_ARCHITECTURE%
echo osbit : %osbit%
SET CLASSPATH=%CLASSPATH%;conf
jdk\bin\java -cp "%CLASSPATH%"  -Dprism.verbose=true -Djava.awt.headless=false -Dfile.encoding=utf-8 com.gisway.pick.tool.PickToolApplication
pause
GOTO :eof
::GOTO check
